//
//  GridSizeSelect.m
//  Memory Mania
//
//  Created by Sanket Karkhanis on 2/20/12.
//  Copyright 2012 University of Southern California. All rights reserved.
//

#import "GridSizeSelect.h"
#import "GlobalData.h"
#import "HelloWorldLayer.h"
#import "ModeSelect.h"
#import "GameCntrolMenu.h"


@implementation GridSizeSelect

+(id) scene
{
    CCScene *scene = [CCScene node];
    GridSizeSelect *layer = [GridSizeSelect node];
    [scene addChild:layer];
    
    return  scene;
    
}



- (id)init
{
    self = [super init];
    if (self) {
        
        CCMenuItem *r4c3 = [CCMenuItemFont itemFromString:@"4 X 3" target:self selector:@selector(onr4c3:)];
        CCMenuItem *r4c4 = [CCMenuItemFont itemFromString:@"4 X 4" target:self selector:@selector(onr4c4:)];
        CCMenuItem *r4c5 = [CCMenuItemFont itemFromString:@"4 X 5" target:self selector:@selector(onr4c5:)];
        CCMenuItem *back = [CCMenuItemFont itemFromString:@"Back" target:self selector:@selector(onBack:)];    r4c3.scale = 3.0f;
        r4c4.scale = 3.0f;
        r4c5.scale = 3.0f;
        back.scale = 2.0f;
        
        //background
        CCSprite *GSSBg = [CCSprite spriteWithFile:@"sergiu-bacioiu-water-drop-ipad-wallpaper.jpg"];		
        GSSBg.anchorPoint = ccp(0.5,0.5);
        GSSBg.position = ccp(512,384);
		//PSBg.opacity = 70;        
        [self addChild:GSSBg z:0 tag:1];    
        
        //play.position = ccp(700,200);
        CCMenu *menu = [CCMenu menuWithItems:r4c3, r4c4, r4c5, back,nil];
        
        [menu alignItemsVerticallyWithPadding:50.0f];
        [self addChild:menu];
        
                
               
        // Initialization code here.
    }
    
    return self;
}

-(void) onr4c3: (id) sender
{
    NSLog(@"To play Game scene");
    [GlobalData sharedGlobalData].rows = 4;
    [GlobalData sharedGlobalData].cols = 3;
    
    
    CCScene *sc = [CCScene node];        
    [sc addChild:[HelloWorldLayer node]];
    [sc addChild:[GameCntrolMenu node]];    
    [[CCDirector sharedDirector] replaceScene:[CCTransitionJumpZoom transitionWithDuration:1.0 scene:sc]];    
}

-(void) onr4c4: (id) sender
{
    NSLog(@"To play Game Scene");
    [GlobalData sharedGlobalData].rows = 4;
    [GlobalData sharedGlobalData].cols = 4;
    
    CCScene *sc = [CCScene node];        
    [sc addChild:[HelloWorldLayer node]];
    [sc addChild:[GameCntrolMenu node]];    
    [[CCDirector sharedDirector] replaceScene:[CCTransitionJumpZoom transitionWithDuration:1.0 scene:sc]];    

}

-(void) onr4c5: (id) sender
{
    NSLog(@"To play Game Scene");
    [GlobalData sharedGlobalData].rows = 4;
    [GlobalData sharedGlobalData].cols = 5;
    
    CCScene *sc = [CCScene node];        
    [sc addChild:[HelloWorldLayer node]];
    [sc addChild:[GameCntrolMenu node]];    
    [[CCDirector sharedDirector] replaceScene:[CCTransitionJumpZoom transitionWithDuration:1.0 scene:sc]];     

}

-(void) onBack: (id) sender
{
    NSLog(@"Go Backt ot ModeSelect");
    
    [[CCDirector sharedDirector] replaceScene:[CCTransitionFlipY transitionWithDuration:1.0 scene:[ModeSelect node]]]; 
}@end
